Skip to content

Conversation

@adaliszk
Copy link

While trying to use this library in an existing CLI tool (importing it), I ran into a few issues:

  • Types are not exposed as the dist file for it was missing
  • There are no named exports for ESM-based usage

I fixed those issues, and the tests passed as no logic has changed, improving on #8: Support a programmable API.

While so far the default export could have been used, now it is nicely typed and can support both CommonJS and ESM usage:

// CommonJS
const complexity = require("code-complexity")
const results = await complexity.compute({
  target: "some/file/path"
})
// ES Modules
import { analyze } from "code-complexity";

const results = await analyze({
  target: "some/file/path"
})

For advanced usage, people can import Statistics, Churns, and Complexities and instantiate their own Analyzer.

Exposing the various types and classes for programatical usage
with a shortcut for the complexity calculation. This should
give a decent support for functional or object-oriented support
while keeping the changes low.

refs: simonrenoult#8
@adaliszk adaliszk changed the title Quick fixes for DX feat: DX improvements for programmable API Feb 18, 2024
@simonrenoult simonrenoult force-pushed the main branch 2 times, most recently from c9ed4e4 to 59f5c5a Compare August 21, 2025 22:31
@simonrenoult
Copy link
Owner

I made some changes for the incoming v5, I'll take a look at this PR later (hopefully, it won't wait 2 years this time).

@simonrenoult simonrenoult added the enhancement New feature or request label Aug 21, 2025
@simonrenoult simonrenoult force-pushed the main branch 2 times, most recently from 4e99801 to 6244a98 Compare August 22, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants